<template>
  <div class="app-container" v-loading="loading">
    <el-form class="formBox formBox1 searchForm" :model="queryParams" ref="queryForm" size="small" :inline="true"
      v-show="showSearch" label-width="68px">
      <el-form-item label="医院" prop="hospital" clearable>
        <department :isHospital="true" :isdepat="true" @refreshData="refreshData" deptWidth="200px" ref="department">
        </department>
      </el-form-item>
      <el-form-item label="顾客ID" prop="patientId">
        <el-input v-model="queryParams.patientId" placeholder="顾客ID" clearable style="width: 200px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="顾客编号" prop="visitNum">
        <el-input v-model="queryParams.visitNum" placeholder="请输入顾客编号" clearable style="width: 200px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="姓名" prop="patientName">
        <el-input v-model="queryParams.patientName" placeholder="请输入顾客姓名" clearable style="width: 200px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="手机号" prop="patientPhone">
        <el-input v-model="queryParams.patientPhone" placeholder="请输入顾客手机号" clearable style="width: 200px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="身份证号" prop="idNum">
        <el-input v-model="queryParams.idNum" placeholder="顾客身份证号" clearable style="width: 200px" @focus="getSFZToSearch"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择诊断状态" clearable style="width: 200px" @change="handleQuery">
          <el-option v-for="dict in dict.type.sys_diagnosis_status" :key="dict.value" :label="dict.label"
            :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label="治疗医生" prop="treatmentDoctor">
        <el-select v-model="queryParams.treatmentDoctor" filterable clearable placeholder="治疗医生" style="width: 200px" @change="handleQuery">
          <el-option v-for="(item, index) in doctorList" :key="index" :label="item.nickName"
            :value="item.userName" ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="治疗名称" prop="packageContent">
        <el-select v-model="queryParams.packageContent" placeholder="请选择治疗名称" filterable clearable style="width: 200px" @change="handleQuery">
          <el-option v-for="item in singlePlanList" :key="item.planId" :label="item.medicalEquipment"
            :value="item.medicalEquipment" ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="治疗仪器" prop="treatmentInstrument">
        <el-select v-model="queryParams.treatmentInstrument" placeholder="请选择治疗仪器" filterable clearable
          style="width: 200px" @change="handleQuery">
          <el-option v-for="item in instrumentsList" :key="item.deviceId" :label="item.deviceName"
            :value="item.deviceId" ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="治疗部位" prop="treatmentPlace">
        <el-select v-model="queryParams.treatmentPlace" clearable filterable @focus="openCollapse" placeholder="请选择治疗部位"
          style="width: 200px" @change="handleQuery">
          <el-option v-for="(dict, index) in dict.type.sys_face_part" :key="index" :label="dict.label"
            :value="dict.label" ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="治疗效果" prop="treatmentEffect">
        <el-select v-model="queryParams.treatmentEffect" filterable clearable placeholder="请选择治疗效果" style="width: 200px" @change="handleQuery">
          <el-option v-for="dict in dict.type.sys_treatment_effect" :key="dict.value" :label="dict.label"
            :value="dict.value" ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="治疗日期">
        <el-date-picker v-model="dateRange" :picker-options="pickerOptions" style="width: 240px" value-format="yyyy-MM-dd"
          type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
          @change="handleQuery"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <div class="formBox searchForm" style="margin-bottom:0px!important;" ref="statisticalTable">
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
            v-hasPermi="['treatmentWorkstation:treatmentManagement:add']">新增</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
            v-hasPermi="['treatmentWorkstation:treatmentManagement:edit']">修改</el-button>
        </el-col>

        <el-col :span="1.5">
          <el-button type="danger" icon="el-icon-s-platform" size="mini" @click="handlescan"
            :disabled="queryParams.packageContent ? false : true">单项治疗汇总明细</el-button>
        </el-col>
        <el-col :span="9">
          <span style="color:red;font-size:12px;">(注意：先选择治疗名称和查询的日期，再查看明细)</span>
        </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getTreatmentList"></right-toolbar>
      </el-row>

      <el-table border v-loading="loading" style="width: 100%" :data="patientList"
        @selection-change="handleSelectionChange" :height="statisticalTableH" ref="table">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="序号" align="center" type="index" width="50">
          <template slot-scope="scope">
            <span>{{ getIndex(scope.$index) }}</span>
          </template>
        </el-table-column>
        <el-table-column sortable label="顾客ID" align="center" prop="patientId" :show-overflow-tooltip="true"
          width="100" />
        <el-table-column sortable label="顾客编号" align="center" prop="visitNum" width="160">
          <template slot-scope="scope">
            <el-tooltip placement="right" effect="light">
              <div slot="content" v-html="renderTooltip(scope.row)" style="max-width: 700px" />
              <span style="text-decoration: underline;color: #10a1df; ">
                {{ scope.row.visitNum }}
              </span>
            </el-tooltip>
          </template>
        </el-table-column>
        <el-table-column sortable label="顾客姓名" align="center" prop="patientName" :show-overflow-tooltip="true"
          width="100" />
        <el-table-column sortable label="治疗年龄" align="center" prop="treatmentAge" :show-overflow-tooltip="true"
          width="100" />


        <el-table-column sortable label="状态" align="center" prop="status" :show-overflow-tooltip="true" width="120">
          <!--          <template slot-scope="scope">-->
          <!--            <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />-->
          <!--          </template>-->
          <template slot-scope="scope">
            <el-tag v-if="scope.row.status == '0'" type="danger" size="mini">
              <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
            </el-tag>
            <el-tag v-else-if="scope.row.status == '1'" type="warning" size="mini">
              <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
            </el-tag>
            <el-tag v-else-if="scope.row.status == '3'" type="success" size="mini">
              <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
            </el-tag>
            <el-tag v-else-if="scope.row.status == '4'" size="mini">
              <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column sortable label="治疗名称" align="center" prop="packageContent" width="100" />
        <el-table-column sortable label="治疗仪器" align="center" prop="instruments" width="180" />
        <el-table-column sortable label="治疗价格" align="center" prop="treatmentPrice" width="100" />

        <el-table-column sortable label="治疗反应" align="center" prop="treatmentReaction" width="100">
          <template slot-scope="scope">
            <span>{{ getTreatmentReactionText(scope.row.treatmentReaction) }}</span>
            <!-- <dict-tag :options="dict.type.sys_treatment_reaction" :value="scope.row.treatmentReaction" /> -->
          </template>
        </el-table-column>
        <el-table-column sortable label="治疗部位" align="center" prop="treatmentPlace" width="140"
          :show-overflow-tooltip="true">
        </el-table-column>
        <el-table-column sortable label="治疗参数" align="center" prop="remark" width="200" :show-overflow-tooltip="true">
        </el-table-column>
        <el-table-column sortable label="治疗效果" align="center" prop="treatmentEffect" width="100">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_treatment_effect" :value="scope.row.treatmentEffect" />
          </template>
        </el-table-column>
        <el-table-column sortable label="治疗日期" align="center" prop="consultationDate" width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.treatmentTime) }}</span>
          </template>
        </el-table-column>

        <el-table-column sortable label="治疗医生" align="center" prop="treatmentDoctorName" width="100">
          <template slot-scope="scope">
            <span>{{ scope.row.treatmentDoctorName ? scope.row.treatmentDoctorName : scope.row.treatmentDoctor }}</span>
          </template>
        </el-table-column>
        <el-table-column sortable label="录入员" align="center" prop="nickName" width="100">
          <template slot-scope="scope">
            <span>{{ scope.row.nickName ? scope.row.nickName : scope.row.createBy }}</span>
          </template>
        </el-table-column>
        <el-table-column sortable label="录入日期" align="center" prop="createTime" width="100">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createTime) }}</span>
          </template>
        </el-table-column>

        <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width" width="100">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-user" @click="goDetail(scope.row)"
              v-hasPermi="['treatmentWorkstation:treatmentManagement:detail']">详情</el-button>
          </template>
        </el-table-column>
      </el-table>


      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getTreatmentList" />

    </div>

    <!-- 添加或修改顾客信息对话框 -->
    <el-dialog :title="recordTitle" :visible.sync="recordVisible" width="85%" append-to-body :close-on-click-modal="false"
      :before-close="closeRecord" v-dialogDrag>
      <!--      <el-form v-show="submitStatus" class="formBox" :model="recordQueryParams" ref="recordQueryForm" size="small" :inline="true"  label-width="68px">-->
      <el-form class="formBox" :model="recordQueryParams" ref="recordQueryForm" size="small" :inline="true"
        label-width="68px">

        <el-form-item label="顾客编号" prop="visitNum">
          <el-input v-model="recordQueryParams.visitNum" :disabled="!submitStatus" placeholder="请输入顾客编号" clearable
            style="width: 160px" @keyup.enter.native="recordHandleQuery" />
        </el-form-item>
        <el-form-item label="姓名" prop="patientName" label-width="48px">
          <el-input v-model="recordQueryParams.patientName" :disabled="!submitStatus" placeholder="请输入顾客姓名" clearable
            style="width:140px" @keyup.enter.native="recordHandleQuery" />
        </el-form-item>
        <el-form-item label="手机号" prop="patientPhone" label-width="60px">
          <el-input v-model="recordQueryParams.patientPhone" :disabled="!submitStatus" placeholder="请输入手机号" clearable
            style="width: 140px" @keyup.enter.native="recordHandleQuery" />
        </el-form-item>
        <el-form-item label="身份证号" prop="idNum">
          <el-input v-model="recordQueryParams.idNum" :disabled="!submitStatus" placeholder="请输入顾客身份证号" clearable
            style="width: 170px" @keyup.enter.native="recordHandleQuery" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" :disabled="!submitStatus"
            @click="recordHandleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" :disabled="!submitStatus" @click="recordResetQuery">重置</el-button>
        </el-form-item>
        <el-form-item>
          <el-badge :value="confirmPayNum" class="totalItem">
            <el-button type="success" :disabled="!patientItem.visitNum" plain icon="el-icon-s-custom" size="mini"
              @click="confirmPay">缴费确认</el-button>
          </el-badge>
          <el-badge :value="confirmKnowNum" class="totalItem">
            <el-button type="success" :disabled="!patientItem.visitNum" plain icon="el-icon-picture" size="mini"
              @click="confirmKnow">知情同意书</el-button>
          </el-badge>
          <el-badge :value="positionSchemeNum" class="totalItem">
            <el-button type="success" plain :disabled="!patientItem.visitNum" icon="el-icon-picture" size="mini"
              @click="positionScheme">部位示意</el-button>
          </el-badge>
          <el-badge :value="uploadPhotosNum" class="totalItem">
            <el-button type="success" plain :disabled="!patientItem.visitNum" icon="el-icon-picture" size="mini"
              @click="uploadPhotos">上传治疗照片</el-button>
          </el-badge>
          <el-badge :value="warmReminderRecordParamsTotal" class="totalItem">
            <el-button type="success" plain :disabled="!patientItem.visitNum" icon="el-icon-document" size="mini"
              @click="warmReminder">温馨提示</el-button>
          </el-badge>

        </el-form-item>
      </el-form>
      <el-form class="formBox formBox1 activeNameBox" label-position="left" :model="patientItem" ref="patientItemForm"
        size="small" :inline="true" label-width="68px">

        <el-collapse v-model="activeName" accordion @change="handleChange">
          <el-collapse-item title="诊断信息" name="1">
            <el-row>
              <el-form-item label="顾客编号" prop="visitNum">
                <el-input v-model="patientItem.visitNum" placeholder="顾客编号" clearable style="width: 160px"
                  :disabled="true" />
              </el-form-item>
              <el-form-item label="姓名" prop="patientName">
                <el-input v-model="patientItem.patientName" placeholder="顾客姓名" clearable style="width: 160px"
                  :disabled="true" />
              </el-form-item>
              <el-form-item label="性别" prop="sex">
                <el-select :disabled="true" v-model="patientItem.sex" placeholder="性别" clearable style="width: 160px">
                  <el-option v-for="dict in dict.type.sys_user_sex" :key="dict.value" :label="dict.label"
                    :value="dict.value" />
                </el-select>
              </el-form-item>
              <el-form-item label="年龄" prop="age">
                <el-input v-model="patientItem.age" placeholder="顾客年龄" clearable style="width: 160px" :disabled="true" />
              </el-form-item>
              <el-form-item label="手机号" prop="patientPhone">
                <el-input v-model="patientItem.patientPhone" placeholder="顾客手机号" clearable style="width: 160px"
                  :disabled="true" />
              </el-form-item>
            </el-row>
            <el-row>
              <el-form-item label="状态" prop="status">
                <el-select v-model="patientItem.status" placeholder="诊断状态" clearable style="width: 160px"
                  :disabled="true">
                  <el-option v-for="dict in dict.type.sys_diagnosis_status" :key="dict.value" :label="dict.label"
                    :value="dict.value" />
                </el-select>
              </el-form-item>
              <el-form-item label="诊断医生" prop="doctor">
                <el-input v-model="patientItem.doctor" placeholder="诊断医生" clearable style="width: 160px"
                  :disabled="true" />
              </el-form-item>
              <el-form-item label="初诊日期" prop="doctorTime">
                <el-input v-model="patientItem.doctorTime" placeholder="初诊日期" clearable style="width: 160px"
                  :disabled="true" />
              </el-form-item>
              <el-form-item label="咨询医生" prop="consultationer">
                <el-input v-model="patientItem.consultationer" placeholder="咨询医生" clearable style="width: 160px"
                  :disabled="true" />
              </el-form-item>
              <el-form-item label="确费状态" prop="confirmExpense">
                <el-input v-model="patientItemConfirmExpense" class="inputRed" placeholder="缴费状态" clearable
                  style="width: 160px;" :disabled="true" />
              </el-form-item>
            </el-row>
            <div>
              <el-form-item label="医生诊断" prop="doctorDiagnosis">
                <el-input v-model="patientItem.doctorDiagnosis" type="textarea" :rows="3" placeholder="医生诊断" clearable
                  style="width: 400px" :disabled="true" />
              </el-form-item>
              <el-form-item label="医生方案" prop="doctorPlan">
                <el-input v-model="patientItem.doctorPlan" type="textarea" :rows="3" placeholder="医生方案" clearable
                  style="width: 400px" :disabled="true" />
              </el-form-item>
            </div>

          </el-collapse-item>
        </el-collapse>

      </el-form>
      <div class="formBox treatmentParametersListBox"
        v-if="treatmentParametersList && treatmentParametersList.length > 0">
        <div class="smallBox" @click="showtreatHistoryDialogVisible">
          <el-button size="medium" type="success">
            <span class="numBox">治疗历史</span>
          </el-button>
        </div>
        <div class="smallBox" v-for="(item, index) in treatmentParametersList" :key="index">
          <el-button size="medium" :disabled="!submitStatus" :type="index == btnIndex ? 'primary' : ''"
            @click="getTreatmentParametersItem(item, index)">
            <!--            {{item.packageContent }}*{{ item.num }}次,余{{ item.spareNum }}次-->
            <span>{{ item.packageContent }}</span>
            <span class="numBox"> {{ item.num }} </span>次,余
            <span class="numBox">{{ item.spareNum }} </span>次
          </el-button>
        </div>
      </div>


      <el-form class="formBox" :model="treatmentItemForm" ref="treatmentItemForm" :rules="treatmentItemFormRules"
        size="small" label-width="88px">
        <div class="treatmentInlineBox">
          <el-form-item label="治疗仪器" prop="treatmentInstrument">
            <el-select v-model="treatmentItemForm.treatmentInstrument" multiple filterable clearable
              placeholder="请选择常用治疗仪器名称" style="width: 307px">
              <el-option v-for="item in instrumentsList" :key="item.deviceId" :label="item.deviceName"
                :value="item.deviceId"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="治疗日期" prop="treatmentTime">
            <!--          <el-date-picker v-model="treatmentItemForm.treatmentTime" align="left" value-format="yyyy-MM-dd HH:mm:ss"  type="datetime" placeholder="选择日期"-->
            <el-date-picker v-model="treatmentItemForm.treatmentTime" align="left" type="datetime" placeholder="选择日期"
              :picker-options="treatmentItemFormPickerOptions" style="width: 200px">
            </el-date-picker>
          </el-form-item>
          <el-form-item label-width="0">
            <el-button type="success" size="mini" @click="showtreatmentRecordData" style="margin-left: 20px;">历史治疗记录 <span
                style="color:red;">({{ submitStatus ? treatmentRecordDataList.length : treatmentRecordDataList.length - 1
                }} 次）
              </span></el-button>
          </el-form-item>
        </div>
        <div class="treatmentInlineBox">
          <el-form-item label="治疗反应" prop="treatmentReaction">
            <el-select v-model="treatmentItemForm.treatmentReaction" multiple filterable clearable placeholder="治疗反应"
              style="width: 220px">
              <el-option v-for="dict in dict.type.sys_treatment_reaction" :key="dict.value" :label="dict.label"
                :value="dict.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="治疗效果" prop="treatmentEffect">
            <el-select v-model="treatmentItemForm.treatmentEffect" filterable clearable placeholder="治疗效果"
              style="width: 100px">
              <el-option v-for="dict in dict.type.sys_treatment_effect" :key="dict.value" :label="dict.label"
                :value="dict.value"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="治疗医生" prop="treatmentDoctor">
            <el-select v-model="treatmentItemForm.treatmentDoctor" filterable clearable placeholder="治疗医生"
              style="width: 100px">
              <el-option v-for="(item, index) in doctorListCopy" :key="index" :label="item.nickName"
                :value="item.userName"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="治疗价格" prop="treatmentPrice">
            <el-input v-model="treatmentItemForm.treatmentPrice" clearable style="width: 100px" />
          </el-form-item>
          <el-form-item label="点位数" prop="pointsNum" v-if="submitStatus">
            <el-input v-model="treatmentItemForm.pointsNum" clearable style="width: 100px" />
          </el-form-item>

        </div>
        <div class="mt15">
          <el-collapse v-model="activeName1" accordion>
            <el-form-item class="mt10" label="治疗部位" clearable>
              <el-select v-model="treatmentItemForm.treatmentPlace" multiple clearable filterable @focus="openCollapse"
                placeholder="请选择部位" style="width: 90%">
                <el-option v-for="(dict, index) in dict.type.sys_face_part" :key="index" :label="dict.label"
                  :value="dict.label"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="" prop="treatmentPlace">
              <el-collapse-item name="1">
                <el-checkbox-group v-model="treatmentItemForm.treatmentPlace">
                  <el-checkbox v-for="(dict, index ) in dict.type.sys_face_part" :key="index" :label="dict.label"
                    :value="dict.value" style="width: 100px;"></el-checkbox>
                </el-checkbox-group>
              </el-collapse-item>
            </el-form-item>
          </el-collapse>
        </div>
        <div class="treatmentInlineBox">
          <el-form-item label="治疗参数" prop="remark" style="margin-top: 10px">
            <el-input type="textarea" :rows="3" v-model="treatmentItemForm.remark" clearable style="width: 300px;" />
          </el-form-item>
          <el-form-item label="医嘱参数" prop="treatmentParameter" style="margin-top: 10px">
            <el-input type="textarea" :disabled="true" :rows="3" v-model="treatmentItemForm.treatmentParameter" clearable
              style="width: 300px;" />
          </el-form-item>
          <el-form-item label="备注" prop="treatmentRemark" style="margin-top: 10px">
            <el-input type="textarea" :rows="3" v-model="treatmentItemForm.treatmentRemark" clearable
              style="width: 300px;" />
          </el-form-item>
        </div>

        <div class="treatmentParametersListBoxBtn" v-if="parametersList.length > 0">
          <span class="smallTitle">修改治疗参数：</span>
          <div class="smallBox" v-for="(item, index) in parametersList" :key="index">
            <el-form-item :label="item.label">
              <el-input v-model="item.value" placeholder="请输入内容"></el-input>
            </el-form-item>
          </div>
          <el-form-item>
            <el-button size="mini" type="danger" @click="addTreatmentParameters">修改</el-button>
          </el-form-item>
        </div>
      </el-form>

      <div>
        <el-button type="primary" class="formBtn" v-if="submitStatus" @click="attendItem">提 交</el-button>
        <el-button type="primary" class="formBtn" v-else @click="updateTreatmentItem">修 改</el-button>
      </div>


    </el-dialog>
    <el-dialog title="选择顾客" :visible.sync="patientVisible" width="80%" :close-on-click-modal="false" v-dialogDrag>
      <div class="formBox">
        <el-table border v-loading="loading" style="width: 100%" :data="recordPatientList">
          <el-table-column label="序号" align="center" type="index" width="50">
            <template slot-scope="scope">
              <span>{{ getRecordIndex(scope.$index) }}</span>
            </template>
          </el-table-column>
          <el-table-column sortable label="顾客编号" align="center" prop="visitNum" width="160" />
          <el-table-column sortable label="顾客姓名" align="center" prop="patientName" :show-overflow-tooltip="true"
            width="100" />
          <el-table-column sortable label="顾客手机号" align="center" prop="patientPhone" :show-overflow-tooltip="true"
            width="120" />
          width="180" />
          <el-table-column sortable label="性别" align="center" prop="sex" width="80">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex" />
            </template>
          </el-table-column>
          <el-table-column sortable label="年龄" align="center" prop="age" width="80" />
          <el-table-column sortable label="就诊门诊" align="center" prop="deptName" :show-overflow-tooltip="true" />

          <el-table-column sortable label="状态" align="center" prop="status" :show-overflow-tooltip="true" width="120">
            <!--            <template slot-scope="scope">-->
            <!--              <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />-->
            <!--            </template>-->
            <template slot-scope="scope">
              <el-tag v-if="scope.row.status == '0'" type="danger" size="mini">
                <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
              </el-tag>
              <el-tag v-else-if="scope.row.status == '1'" type="warning" size="mini">
                <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
              </el-tag>
              <el-tag v-else-if="scope.row.status == '3'" type="success" size="mini">
                <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
              </el-tag>
              <el-tag v-else-if="scope.row.status == '4'" size="mini">
                <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column sortable label="顾客性质" align="center" prop="properties" width="100">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.sys_patient_properties" :value="scope.row.properties" />
            </template>
          </el-table-column>
          <el-table-column sortable label="登记人" align="center" prop="createBy" width="120"
            :show-overflow-tooltip="true" />
          <el-table-column sortable label="登记日期" align="center" prop="createTime" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column fixed="right" label="操作" align="center" class-name="small-padding fixed-width" width="100">
            <template slot-scope="scope">
              <el-button size="mini" type="text" icon="el-icon-caret-right"
                @click="confirmPatient(scope.row)">点击选择</el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination v-show="searchTotal > 0" :total="searchTotal" :pageSizes.sync="recordPageSizes"
          :page.sync="recordQueryParams.pageNum" :limit.sync="recordQueryParams.pageSize"
          @pagination="getRecordPatientList" />
      </div>
    </el-dialog>
    <el-dialog title="缴费确认" :visible.sync="confirmPayVisible" :width="device !== 'mobile' ? '650px' : '100%'"
      class="nopaddingDailog" :class="device !== 'mobile' ? '' : 'active'" append-to-body :close-on-click-modal="false"
      :before-close="closeConfirmPay" v-dialogDrag>

      <div class="uploadBtnBox">
        <el-button type="primary" plain icon="el-icon-s-custom" size="mini"
          @click="uploadImageConfirmPay">上传凭证</el-button>
        <!--        <el-button class="btn" type="primary" plain icon="el-icon-picture" size="mini" >拍摄凭证</el-button>-->
        <el-button class="btn" type="primary" plain icon="el-icon-picture" size="mini" @click="openShooting('0')"
          v-if="device !== 'mobile'">拍摄凭证</el-button>
      </div>

      <div class="uploadImageBox" v-loading="loading">
        <div v-for="(item, index) in confirmPayImageInfo" :key="index" class="draggable-item">
          <div class="icon-close" v-if="!item.visitNum" @click="removeImgConfirmPay(item, index)">
            <i class="el-icon-close" style="background-color: #fff;color:red;font-weight: bold"></i>
          </div>
          <el-image style="width: 200px; height: 130px" :src="item.url" fit="fill" :preview-src-list="confirmPaySrcList">
          </el-image>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleCloseConfirmPay('0')">确认已缴费</el-button>
      </div>
    </el-dialog>

    <el-dialog title="知情同意书确认" :visible.sync="confirmKnowVisible" :width="device !== 'mobile' ? '650px' : '100%'"
      class="nopaddingDailog" :class="device !== 'mobile' ? '' : 'active'" append-to-body :close-on-click-modal="false"
      :before-close="closeConfirmKnow" v-dialogDrag>
      <div class="uploadBtnBox">
        <el-button type="primary" plain icon="el-icon-s-custom" size="mini" @click="uploadImage">上传知情同意书</el-button>
        <el-button class="btn" type="primary" plain icon="el-icon-picture" size="mini" @click="openShooting('1')"
          v-if="device !== 'mobile'">拍摄知情同意书</el-button>
      </div>
      <div class="uploadImageBox" v-loading="loading">
        <div v-for="(item, index) in imageInfo" :key="index" class="draggable-item">
          <div class="icon-close" v-if="!item.visitNum" @click="removeImg(item, index)">
            <i class="el-icon-close" style="background-color: #fff;color:red;font-weight: bold"></i>
          </div>
          <el-image style="width: 138px; height: 200px" :src="item.url" fit="fill" :preview-src-list="srcList">
          </el-image>
        </div>
        <!--        <el-image class="img-style" :src="confirmPayUrl" :preview-src-list="srcList"></el-image>-->
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleCloseConfirmKnow('1')">确认已签署</el-button>
      </div>

    </el-dialog>
    <el-dialog title="部位示意" :visible.sync="positionSchemeVisible" :width="device !== 'mobile' ? '650px' : '100%'"
      class="nopaddingDailog" :class="device !== 'mobile' ? '' : 'active'" append-to-body :close-on-click-modal="false"
      :before-close="closePositionScheme" v-dialogDrag>

      <div class="uploadBtnBox positionSchemeBox">
        <div>
          <el-button type="primary" plain icon="el-icon-s-custom" size="mini"
            @click="uploadImagePositionScheme">部位</el-button>
        </div>

      </div>
      <div class="uploadImageBox" v-loading="loading">
        <div v-for="(item, index) in positionSchemeImageInfo" :key="index" class="draggable-item">
          <div class="icon-close" v-if="!item.visitNum" @click="removeImgPositionScheme(item, index)">
            <i class="el-icon-close" style="background-color: #fff;color:red;font-weight: bold"></i>
          </div>
          <el-image style="width: 146px; height: 230px" :src="item.url" fit="fill"
            :preview-src-list="positionSchemeSrcList">
          </el-image>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleClosePositionScheme('2')">确认上传</el-button>
      </div>
    </el-dialog>
    <el-dialog title="上传治疗照片" :visible.sync="uploadPhotosVisible" :width="device !== 'mobile' ? '650px' : '100%'"
      class="nopaddingDailog" :class="device !== 'mobile' ? '' : 'active'" append-to-body :close-on-click-modal="false"
      :before-close="closeUploadPhotos" v-dialogDrag>
      <div class="uploadBtnBox">
        <el-button type="primary" plain icon="el-icon-s-custom" size="mini"
          @click="uploadImageUploadPhotos">上传治疗照片</el-button>
        <el-button class="btn" type="primary" plain icon="el-icon-picture" size="mini" @click="openShooting('3')"
          v-if="device !== 'mobile'">拍摄治疗照片</el-button>

      </div>
      <div class="uploadImageBox" v-loading="loading">
        <div v-for="(item, index) in uploadPhotosImageInfo" :key="index" class="draggable-item">
          <div class="icon-close" v-if="!item.visitNum" @click="removeImgUploadPhotos(item, index)">
            <i class="el-icon-close" style="background-color: #fff;color:red;font-weight: bold"></i>
          </div>
          <el-image style="width: 146px; height: 230px" :src="item.url" fit="fill"
            :preview-src-list="uploadPhotosSrcList">
          </el-image>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleCloseUploadPhotos('3')">确认上传</el-button>
      </div>
    </el-dialog>
    <!-- 治疗历史 -->
    <el-dialog title="治疗历史" :visible.sync="treatHistoryDialogVisible" width="85%" append-to-body v-dialogDrag
      :close-on-click-modal="false">
      <treatmentHistory v-if="treatHistoryDialogVisible" :basicInfo="patientItem"></treatmentHistory>
    </el-dialog>
    <!-- 详情 -->
    <el-dialog :title="detailTitle" :visible.sync="detailDialogVisible" width="85%" append-to-body v-dialogDrag
      :close-on-click-modal="false">
      <CustomerDetails v-if="detailDialogVisible" :basicInfo="baseInfo"></CustomerDetails>
    </el-dialog>
    <!-- 温馨提示 -->
    <el-dialog title="温馨提示" :visible.sync="warmReminderVisible" v-dialogDrag width="90%" append-to-body
      :close-on-click-modal="false" :before-close="closeWarmReminderVisible">
      <warmReminder v-if="warmReminderVisible" :baseInfo="patientItem"
        @closeWarmReminderVisible="closeWarmReminderVisible"></warmReminder>
    </el-dialog>
    <!-- 调取摄像头拍摄 -->
    <el-dialog title="拍照" :visible.sync="cameraShootingVisible" v-dialogDrag
      :width="device !== 'mobile' ? '650px' : '100%'" class="nopaddingDailog" :class="device !== 'mobile' ? '' : 'active'"
      append-to-body :close-on-click-modal="false">
      <shooting v-if="cameraShootingVisible" :cameraShootingVisible="cameraShootingVisible"
        @closeShooting="closeShooting"></shooting>
    </el-dialog>
    <!-- 治疗历史 -->
    <el-dialog title="历史治疗记录" :visible.sync="treatrecordDialogVisible" width="80%" append-to-body v-dialogDrag
      :close-on-click-modal="false">
      <treatmentCitate v-if="treatrecordDialogVisible" :basicInfo="patientItem" :currentItem="uploadPackageContent"
        @comfirmCitate="comfirmCitateSubmit"></treatmentCitate>
    </el-dialog>

    <!-- 查看明细 -->
    <el-dialog :title="diseaseAndtreatTitle" class="nopaddingDailog" :visible.sync="diseaseAndtreatDailog"
      @close="closeDiseaseAndtreatDailog" width="90%">
      <el-row :gutter="10" class="mb8">

        <el-col :span="1.5">
          <el-button type="success" icon="el-icon-printer" size="mini" @click="handleExport">明细导出</el-button>

        </el-col>
        <el-col :span="12">
          <el-tag type="danger" size="small">此项治疗共计人次：{{ alltableDataTotal }}</el-tag>
        </el-col>
      </el-row>
      <div class="formBox" v-if="diseaseAndtreatDailog">
        <el-table border v-loading="loading" style="width: 100%" :data="alltableData" height="calc(100vh - 180px)"
          ref="diseaseAndtreattable" id="diseaseAndtreattable">
          <el-table-column label="序号" align="center" type="index" width="80">
            <template slot-scope="scope">
              <span>{{ getIndex(scope.$index) }}</span>
            </template>
          </el-table-column>
          <el-table-column sortable label="顾客ID" align="center" prop="patientId" :show-overflow-tooltip="true"
            width="100" />
          <!-- <el-table-column sortable label="顾客编号" align="center" prop="visitNum" width="160">
            <template slot-scope="scope">
              <el-tooltip placement="right" effect="light">
                <div slot="content" v-html="renderTooltip(scope.row)" style="max-width: 700px" />
                <span style="text-decoration: underline;color: #10a1df; ">
                  {{ scope.row.visitNum }}
                </span>
              </el-tooltip>
            </template>
          </el-table-column> -->
          <el-table-column sortable label="顾客姓名" align="center" prop="patientName" :show-overflow-tooltip="true"
            width="100" />
          <el-table-column sortable label="治疗年龄" align="center" prop="treatmentAge" :show-overflow-tooltip="true"
            width="100" />


          <!-- <el-table-column sortable label="状态" align="center" prop="status" :show-overflow-tooltip="true" width="120">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.status == '0'" type="danger" size="mini">
                <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
              </el-tag>
              <el-tag v-else-if="scope.row.status == '1'" type="warning" size="mini">
                <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
              </el-tag>
              <el-tag v-else-if="scope.row.status == '3'" type="success" size="mini">
                <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
              </el-tag>
              <el-tag v-else-if="scope.row.status == '4'" size="mini">
                <dict-tag :options="dict.type.sys_diagnosis_status" :value="scope.row.status" />
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column sortable label="治疗名称" align="center" prop="packageContent" width="100" /> -->
          <el-table-column sortable label="治疗仪器" align="center" prop="instruments" width="240" />
          <el-table-column sortable label="治疗价格" align="center" prop="treatmentPrice" width="90" />

          <el-table-column sortable label="治疗反应" align="center" prop="treatmentReaction" width="100">
            <template slot-scope="scope">
              <span>{{ getTreatmentReactionText(scope.row.treatmentReaction) }}</span>
              <!-- <dict-tag :options="dict.type.sys_treatment_reaction" :value="scope.row.treatmentReaction" /> -->
            </template>
          </el-table-column>
          <el-table-column sortable label="治疗部位" align="center" prop="treatmentPlace" width="140"
            :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column sortable label="治疗参数" align="center" prop="remark" width="200" :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column sortable label="治疗效果" align="center" prop="treatmentEffect" width="100">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.sys_treatment_effect" :value="scope.row.treatmentEffect" />
            </template>
          </el-table-column>
          <el-table-column sortable label="治疗日期" align="center" prop="consultationDate" width="150">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.treatmentTime) }}</span>
            </template>
          </el-table-column>

          <el-table-column sortable label="治疗医生" align="center" prop="treatmentDoctorName" width="100" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <span>{{ scope.row.treatmentDoctorName ? scope.row.treatmentDoctorName : scope.row.treatmentDoctor }}</span>
            </template>
          </el-table-column>
          <!-- <el-table-column sortable label="录入员" align="center" prop="nickName" width="100">
            <template slot-scope="scope">
              <span>{{ scope.row.nickName ? scope.row.nickName : scope.row.createBy }}</span>
            </template>
          </el-table-column>
          <el-table-column sortable label="录入日期" align="center" prop="createTime" width="100">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
          </el-table-column> -->


        </el-table>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import { mapGetters } from "vuex";
//引入安装的依赖
import * as XLSX from "xlsx";
import * as FileSaver from "file-saver";
import XLSXD from "xlsx-style";
import {
  addsign,
} from "@/api/comfirmAttend/comfirmAttend";
import {listPlan, listPlanDept} from "@/api/system/plan";
import { startReadCard } from "@/utils/getIdCard"
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import Formpreview from "@/views/system/form/Formpreview";
import {
  addTreatment,
  deleteTreatment,
  getListForTreatment,
  getTreatmentDetail, getTreatmentDoctorUsers,
  getTreatmentList, updateTreatment,
  findSysVisitPlans, findTreatmentBy, getTreatmentBy, consentUploads, consentNum, consentList, treatmentListAll
} from "@/api/treatmentWorkstation/treatmentManagement";
import CustomerDetails from "@/views/components/customerDetail/customerDetail";
import treatmentHistory from "@/views/components/customerDetail/treatmentHistory";
import MoreImage from "@/views/components/uploadImage/moreImage";
import shooting from "@/views/components/camera/shooting"
// 导入的方法将使用文件系统
// 访问API或回退实现。
import {
  fileOpen,
  directoryOpen,
  fileSave,
  supported,
} from 'browser-fs-access';
import { listClassify } from "@/api/system/classify";
import { listText } from "@/api/system/text";
import { getListUser, getUser, listUser } from "@/api/system/user";
import { addTips, getTipsList } from "@/api/warmReminder/warmReminder";
import warmReminder from "@/views/components/warmReminder/warmReminder";
import { listDevice } from "@/api/system/device";
import department from "@/views/components/department/index.vue";
import treatmentCitate from "@/views/components/customerDetail/treatmentCitate";
export default {
  name: "TreatmentManagement",
  dicts: [
    "sys_diagnosis_status",
    "sys_user_sex",
    "sys_patient_properties",
    "sys_skin_tone",
    "sys_patient_sort",
    "sys_outpatient_clinic",
    "sys_general_questionnaire",
    "sys_patient_reason",
    "sys_face_part",
    "sys_treatment_reaction",
    "sys_treatment_effect",

  ],
  components: { Treeselect, Formpreview, CustomerDetails, MoreImage, warmReminder, shooting, treatmentHistory, department, treatmentCitate },

  data() {
    return {
      pickerOptions: {
        disabledDate(time) {
                    return time.getTime() > Date.now() - 8.64e6;  //如果没有后面的-8.64e6就是不可以选择今天的
                },
        shortcuts: [{
          text: '今天',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '昨天',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24);
            const end = date;
            const start = date;
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '前天',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24 * 2);
            const end = date;
            const start = date;
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近六个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 180);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近1年',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 365);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      baseUrl: process.env.VUE_APP_BASE_API,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      patientNames: [],
      patientVisitNum: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 治疗列表
      patientList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        patientId: undefined,
        visitNum: undefined,
        patientName: undefined,
        patientPhone: undefined,
        idNum: undefined,
        hospitalId: undefined,
        deptId: undefined,
        // status: undefined,
      },
      treatmentRecordDataList: [],
      treatrecordDialogVisible: false,
      // 日期范围
      dateRange: [],
      // 新增信息-------
      submitStatus: true,
      recordVisible: false,
      // 新增标题
      recordTitle: '',
      // 搜索总条数
      searchTotal: 0,
      // 折叠面板
      activeName: '',
      activeName1: '',
      // 新增顾客时单项
      patientItem: {},
      recordPatientList: [],
      // 查询参数
      recordQueryParams: {
        pageNum: 1,
        pageSize: 5,
        visitNum: undefined,
        patientName: undefined,
        patientPhone: undefined,
        idNum: undefined,
      },
      recordPageSizes: [5, 10, 15, 20],
      confirmPayUrl: '',
      confirmSrcList: [],
      treatmentItemForm: {
        // createBy: "",
        // createTime: "",
        // delFlag: "",
        doctorDiagnosis: "",     //医生诊断
        doctorPlanId: "",        //医生方案类
        paymenVoucher: "",       //缴费凭证上传地址
        patientId: '',
        remark: "",              //备注
        treatmentAge: "",        //治疗年龄
        treatmentDoctor: "",     //治疗医生
        treatmentEffect: "",     //治疗效果
        treatmentInstrument: "", //治疗仪器
        treatmentParameter: "",  //治疗参数
        treatmentPlace: [],      //治疗部位
        treatmentPrice: null,    //治疗价格
        treatmentReaction: [],   //治疗反应
        treatmentTime: "",       //治疗时间
        // updateBy: "",
        // updateTime: "",
        visitNum: "",             //顾客编号
        pointsNum: '',            //点位数
        treatmentRemark: '',       //备注
      },
      //治理仪器列表
      instrumentsList: [],
      //方案单项列表
      singlePlanList: [],
      // 表单校验
      treatmentItemFormRules: {
        treatmentReaction: [
          {
            required: true,
            message: "治疗反应不能为空",
            trigger: "blur",
          },
        ],
        treatmentEffect: [
          {
            required: true,
            message: "治疗效果不能为空",
            trigger: "blur",
          },
        ],
        treatmentTime: [
          {
            required: true,
            message: "治疗日期不能为空",
            trigger: "blur",
          },
        ],
        treatmentPrice: [
          {
            required: true,
            message: "治疗价格不能为空",
            trigger: "blur",
          },
        ],
        treatmentDoctor: [
          {
            required: true,
            message: "治疗者不能为空",
            trigger: "blur",
          },
        ],
        treatmentPlace: [
          {
            required: true,
            message: "治疗部位不能为空",
            trigger: "blur",
          },
        ],

      },
      treatmentItemFormPickerOptions: {
        shortcuts: [
          {
            text: '今天',
            onClick(picker) {
              picker.$emit('pick', new Date());
            }
          }
        ]
      },
      treatmentParametersList: [],
      btnIndex: 0,
      treatmentParametersItem: {
        category: '',     //类型(1套餐,2单项)
        createBy: '',
        createTime: '',
        diagnosisMedical: '',    //诊断病历
        diagnosisNote: '',       //诊断备注
        diagnosisResult: '',     //诊断结果
        discount: '',            //优惠率
        discountPrice: '',       //优惠价
        dosage: '',              //计量
        expenses: '',            //总费用
        frequency: '',           //频次
        id: '',                  //方案表id
        instruments: '',         //治疗仪器
        isApplication: '',       //是否敷药
        num: '',                 //数量
        numUnit: '',             //数量单位
        packageContent: '',      //套餐内容
        packageName: '',         //套餐名称
        packageNum: '',          //套餐编号
        parameters: '',          //治疗参数
        planCategoryId: '',      //药械大类
        price: '',               //单价价格
        priceUnit: '',           //单价单位
        remark: '',
        searchValue: '',
        spareNum: '',            //剩余数量
        status: '',
        totalPrice: '',          //总价格
        treatmentModalities: '', //用法
        treatmentType: '',       //治疗类别
        type: '',                //诊断类型
        // updateBy:'',
        // updateTime:'',
        visitNum: '',
      },
      //专属医生列表
      doctorList: [],
      //专属医生列表弹窗
      doctorListCopy: [],
      parametersList: [],
      userName: this.$store.state.user.name,
      nickName: this.$store.state.user.nickName,
      uploadPackageContent: '',
      detailTitle: "",
      detailDialogVisible: false,
      baseInfo: {},
      // 顾客选择弹窗
      patientVisible: false,
      confirmPayVisible: false,
      confirmKnowVisible: false,
      positionSchemeVisible: false,
      uploadPhotosVisible: false,
      confirmPayBlobs: [],//获取的本地缴费确认照片信息
      confirmPayImageInfo: [],//上传的缴费确认照片信息
      blobs: [],//获取的知情同意书照片信息
      imageInfo: [],//上传的本地知情同意书照片信息
      positionSchemeBlobs: [], //获取的本地部位示意照片信息
      positionSchemeImageInfo: [], //上传的部位示意照片信息
      uploadPhotosBlobs: [], //获取的本地上传治疗照片信息
      uploadPhotosImageInfo: [], //上传的上传治疗照片信息
      confirmKnowNum: 0,//知情同意书角标
      confirmPayNum: 0,//缴费确认角标
      positionSchemeNum: 0,//部位示意角标
      uploadPhotosNum: 0,//上传治疗照片角标
      warmReminderRecordParamsTotal: 0,//温馨提示角标
      warmReminderVisible: false,
      cameraShootingVisible: false,
      cameraShootingType: '',
      treatHistoryDialogVisible: false,
      statisticalTableH: undefined,
      alltableData: [],
      diseaseAndtreatTitle: '明细',
      diseaseAndtreatDailog: false,
      alltableDataTotal: 0,
    };
  },
  watch: {
    showSearch() {
      this.$nextTick(() => {
        this.changeHeight()
      }, 1000)

    }
  },
  computed: {
    ...mapGetters(["device"]),
    patientItemConfirmExpense() {
      return this.patientItem.confirmExpense == '1' ? '已确费' : '未确费'
    },
    srcList() {
      return this.imageInfo.map(n => n.url) || []
    },
    confirmPaySrcList() {
      return this.confirmPayImageInfo.map(n => n.url) || []
    },
    positionSchemeSrcList() {
      return this.positionSchemeImageInfo.map(n => n.url) || []
    },
    uploadPhotosSrcList() {
      return this.uploadPhotosImageInfo.map(n => n.url) || []
    },
    defaultTime: function () {
      let date = new Date();
      let year = date.getFullYear();
      let month = date.getMonth() + 1;
      let day = date.getDate();
      month = month > 9 ? month : "0" + month;
      day = day < 10 ? "0" + day : day;
      let today = year + "-" + month + "-" + day;
      return [today, today];
    },
  },

  created() {
    this.dateRange = this.defaultTime
    this.getTreatmentList()

  },
  updated() {
    this.$nextTick(() => {
      this.$refs.table.doLayout()
    })
  },
  mounted() {
    this.getInstrumentsList()
    this.getSinglePlanList()
    this.changeHeight()

  },
  methods: {
    handleExport() {
            let tables = document.getElementById('diseaseAndtreattable').cloneNode(true) // 重点
            if (tables.querySelector(".el-table__fixed")) {
                tables.removeChild(tables.querySelector(".el-table__fixed")) // 重点
            }
            let wb = XLSX.utils.table_to_book(tables, { sheet: '统计' })
            this.setExlStyle(wb['Sheets']['统计'])
            //合并单元格边框补齐
            this.addRangeBorder(wb['Sheets']['统计']['!merges'], wb['Sheets']['统计'])
            var ws = XLSXD.write(wb, {
                type: "buffer"
            });
            try {
                FileSaver.saveAs(
                    new Blob([ws], { type: "application/octet-stream" }),
                    `${this.diseaseAndtreatTitle}.xlsx`
                );
            } catch (e) {
                if (typeof console !== "undefined") console.log(e, ws);
            }
            return ws;
        },
        setExlStyle(data) {
            let borderAll = {//单元格外侧框线
                top: {
                    style: 'thin',
                },
                bottom: {
                    style: 'thin'
                },
                left: {
                    style: 'thin'
                },
                right: {
                    style: 'thin'
                }
            };
            data['!cols'] = [];
            for (let key in data) {
                if (data[key] instanceof Object) {
                    data[key].s = {
                        border: borderAll,
                        alignment: {
                            horizontal: 'center',//水平居中对齐
                            vertical: 'center'
                        },
                        font: {
                            sz: 11
                        },
                        bold: true,
                        numFmt: 0
                    }
                    data['!cols'].push({ wpx: 120 });
                }
            }
            return data;
        },
        addRangeBorder(range, ws) {
            let arr = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
          if(range){
            range.forEach(item => {
                let startRowNumber = Number(item.s.c),
                    endRowNumber = Number(item.e.c);
                for (let i = startRowNumber; i <= endRowNumber; i++) {
                    for (let j = Number(item.s.r) + 1; j <= Number(item.e.r); j++) {
                        ws[`${arr[i]}${j + 1}`] = { s: { border: { top: { style: 'thin' }, left: { style: 'thin' }, bottom: { style: 'thin' }, right: { style: 'thin' } } } };
                    }
                }

            })
            return ws;
          }


        },
    closeDiseaseAndtreatDailog() {

    },
    handlescan() {
      this.loading = true;
      this.treatmentListAllEvent()
    },
    treatmentListAllEvent() {//this.addDateRange(this.queryParams, this.dateRange)
      treatmentListAll(this.addDateRange(this.queryParams, this.dateRange)).then(
        (response) => {
          if (response.code == 200) {
            let data = response.data;
            this.alltableData = data
            this.alltableDataTotal = data.length
           this.diseaseAndtreatTitle= `${this.queryParams.packageContent}_${this.dateRange[0]}~${this.dateRange[1]}明细`
            this.diseaseAndtreatDailog = true
            this.$nextTick(() => {
              this.loading = false
            })

          } else {

            this.$modal.msgError(response.msg);
          }

        }
      )
    },
    changeHeight() {
      if (this.$refs.statisticalTable) {
        const statisticalTableObj = this.$refs.statisticalTable.getBoundingClientRect();
        let h = statisticalTableObj.top + 100
        this.statisticalTableH = 'calc(100vh - ' + h + 'px)'
      } else {
        this.statisticalTableH = '500px'
      }
    },
    renderTooltip(row) {
      return `<div style="margin-bottom:5px;font-size:20px;color:#1890ff;"><span style="font-weight:bold;"> 顾客状态：</span>${this.matchDict("sys_diagnosis_status", row.status)}</div>
      <div style="width: 100%;height:1px;background-color: red;margin-bottom:5px;"></div>
      <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">登记日期：</span>${this.parseTime(row.createTime)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">登记人：</span>${this.formatValue(row.createBy)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">就诊科室：</span>${this.formatValue(row.deptName)}</span> </div>
      <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">顾客性质：</span>${this.matchDict("sys_patient_properties", row.properties)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">顾客分类：</span>${this.matchDict("sys_patient_sort", row.customerSort)}</span></div>
      <div style="margin-bottom:5px;font-size:18px"><span style="font-weight:bold;">地址：</span>${this.formatValue(row.address)}</div>
      <div style="margin-bottom:5px;font-size:18px"><span style="font-weight:bold;">电话：</span>${this.formatValue(row.patientPhone)}</div>
      <div style="width: 100%;height:1px;background-color: red;margin-bottom:5px;"></div>
      <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">通用问卷：</span>${this.matchDict("sys_general_questionnaire", row.questionnaireStatus)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">专病问卷：</span>${this.formatValue(row.diseaseQuestionnaireStatus)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">照片：</span>${this.formatValue(row.photoCount)}</span></div>
      <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">咨询日期：</span>${this.formatValue(row.consultationTime)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">咨询医生：</span>${this.formatValue(row.consultationer)}</span></div>
      <div style="margin-bottom:5px;font-size:18px"><span style="font-weight:bold;">咨询诊断：</span>${this.formatValue(row.consultationDiagnosis)}</div>
      <div style="margin-bottom:5px;font-size:18px"><span style="font-weight:bold;">咨询方案：</span>${this.formatValue(row.consultationPlan)}</div>
      <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">方案总额：</span>${this.formatValue(row.consultationTotalExpenses)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">治疗费用：</span>${this.formatValue(row.consultationTreatmentExpenses)}</span></div>
      <div style="width: 100%;height:1px;background-color: red;margin-bottom:5px;"></div>
      <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">诊断日期：</span>${this.formatValue(row.doctorTime)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">诊断医生：</span>${this.formatValue(row.doctor)}</span></div>
      <div style="margin-bottom:5px;font-size:18px"><span style="font-weight:bold;">医生诊断：</span>${this.formatValue(row.doctorDiagnosis)}</div>
      <div style="margin-bottom:5px;font-size:18px"><span style="font-weight:bold;">医生方案：</span>${this.formatValue(row.doctorPlan)}</div>
      <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">方案总额：</span>${this.formatValue(row.doctorTotalExpenses)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">治疗费用：</span>${this.formatValue(row.doctorTreatmentExpenses)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">复诊次数：</span>${this.formatValue(row.reviewNum)}</span></div>
      <div style="width: 100%;height: 1px;background-color: red;margin-bottom:5px;"></div>
      <div style="margin-bottom:5px;font-size:18px"><span style="margin-right:10px;"><span style="font-weight:bold;">知情同意书：</span>${this.formatValue(row.informedConsent)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">确费状态：</span>${this.formatValue(row.confirmExpense == '1' ? '已确费' : '未确费')}</span><span style="margin-right:10px;"><span style="font-weight:bold;">治疗次数：</span>${this.formatValue(row.treatmentTimes)}</span><span style="margin-right:10px;"><span style="font-weight:bold;">温馨提示：</span>${this.formatValue(row.tipsTimes)}</span></div>`
    },
    /** id转化成对应的文字 */
    matchDict: function (key, id) {
      let _this = this;
      const result = _this.dict.type[key];
      let textValue = "";
      result.forEach((item) => {
        if (item.raw.dictValue == id) {
          textValue = item.raw.dictLabel;
        }
      });
      return textValue;
    },
    comfirmCitateSubmit(data) {//治疗记录引用
      // this.treatmentItemForm = {
      //   doctorDiagnosis: "",     //医生诊断
      //   doctorPlanId: "",        //医生方案类
      //   paymenVoucher: "",       //缴费凭证上传地址
      //   remark: "",              //备注
      //   treatmentAge: "",        //治疗年龄
      //   treatmentDoctor: "",     //治疗医生
      //   treatmentEffect: "",     //治疗效果
      //   treatmentInstrument: "", //治疗仪器
      //   treatmentParameter: "",  //治疗参数
      //   treatmentPlace: [],      //治疗部位
      //   treatmentPrice: null,    //治疗价格
      //   treatmentReaction: [],   //治疗反应
      //   treatmentTime: "",       //治疗时间
      //   visitNum: "",            //顾客编号
      //   pointsNum: '',           //点位数
      // }
      console.log(data)
      this.treatmentItemForm.treatmentPlace = data.treatmentPlace.split(',')
      this.treatmentItemForm.treatmentReaction = data.treatmentReaction.split(',')
      this.treatmentItemForm.remark = data.remark
      this.treatmentItemForm.treatmentRemark = data.treatmentRemark
      this.treatmentItemForm.treatmentParameter = data.treatmentParameter
      this.treatmentItemForm.treatmentDoctor = data.treatmentDoctor
      this.treatrecordDialogVisible = false
    },
    showtreatmentRecordData() {
      let num = this.submitStatus ? this.treatmentRecordDataList.length : this.treatmentRecordDataList.length - 1
      if (num > 0) {
        this.treatHistoryDialogVisible = true
      }
    },
    getPartTreatmentList(patientId) {
      let params = {
        pageNum: 1,
        pageSize: 99,
        patientId: patientId,
      }
      getTreatmentList(params).then(
        (response) => {
          if (response.code == 200) {
            this.treatmentRecordDataList = response.rows;
          } else {
            this.$modal.msgError(response.msg);
          }

        }
      )
    },
    formatValue(value) {
      if (value == null) {
        return ''
      } else {
        return value
      }
    },
    getTreatmentReactionText(value) {
      let text = ''
      if (value.includes(',')) {
        let data = value.split(',')
        data.forEach((item, index) => {
          this.dict.type.sys_treatment_reaction.forEach((row) => {
            if (item === row.value) {
              if (index + 1 < data.length) {
                text = `${text + row.label},`
              } else {
                text += row.label
              }
            }
          })
        })
      } else {
        this.dict.type.sys_treatment_reaction.forEach((row) => {
          if (value === row.value) {
            text = row.label
          }
        })
      }
      return text
    },
    refreshData(data) {
      this.queryParams.pageNum = 1;
      this.queryParams.hospitalId = data.hospitalId
      this.queryParams.deptId = data.deptId
      this.getTreatmentDoctorUsersList()

    },
    async getSFZToSearch() {
      const res = await startReadCard()
      if (res.result == 3) {
        this.$message.warning('请把身份证放到读卡器上')
        // this.$refs.saveTagInput.blur();
      } else if (res.result == 2) {
        // this.$message.warning('设备不存在')
      } else {
        this.queryParams.idNum = res.gmsfhm
      }

    },
    // 真实序号计算（计算分页影响）
    getIndex(index) {
      return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1;
    },
    goDetail(row) {
      // this.$router.push("/patientRegistration/patientRegistration-detail/index/" + row.patientId);
      this.detailTitle = '顾客详情'
      this.baseInfo = row
      this.detailDialogVisible = true
    },
    showtreatHistoryDialogVisible() {
      this.treatHistoryDialogVisible = true
    },
    // 修改治疗参数值
    addTreatmentParameters() {
      // this.$set(原数组, 索引值, 需要赋的值)
      if (this.submitStatus) {
        this.$set(this.treatmentParametersList, this.btnIndex, { ...this.treatmentParametersList[this.btnIndex], remark: JSON.stringify(this.parametersList) })
        this.getTreatmentParametersItem(this.treatmentParametersList[this.btnIndex], this.btnIndex)

      } else {
        this.treatmentItemForm.remark = ''
        this.parametersList.forEach((item, index) => {
          this.treatmentItemForm.remark += item.label + '(' + item.value + ');'
        })

      }


    },
    // 获取顾客诊断列表
    getTreatmentList() {
      this.loading = true
      if (this.queryParams.visitNum || this.queryParams.patientId) {
        this.dateRange = []
      }
      getTreatmentList(this.addDateRange(this.queryParams, this.dateRange)).then(
        (response) => {
          if (response.code == 200) {
            this.patientList = response.rows;
            this.total = response.total;
            this.loading = false;
          } else {
            this.loading = false;
            this.$modal.msgError(response.msg);
          }

        }
      )
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getTreatmentList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();

    },

    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.patientNames = selection.map((item) => item.patientName);
      this.patientVisitNum = selection.map((item) => item.visitNum);
      // console.log('handleSelectionChange---', this.ids)
      // console.log('handleSelectionChange---', this.patientVisitNum)

      this.single = selection.length != 1;
      this.multiple = selection.length != 1;
      // this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.recordTitle = '新增治疗'
      this.submitStatus = true
      this.recordVisible = true
      this.btnIndex = 0
      this.treatmentItemForm.treatmentTime = new Date()
      // this.getTreatmentDoctorUsersList()
      this.doctorListCopy = []

      if (this.patientVisitNum.length > 0) {
        this.recordQueryParams.visitNum = this.patientVisitNum[0]
        // console.log('this.recordQueryParams.visitNum--', this.patientVisitNum[0])
        this.recordHandleQuery()
      }

      // if (this.dict.type.sys_treatment_reaction.length > 0) {
      //   this.treatmentItemForm.treatmentReaction = this.dict.type.sys_treatment_reaction[0].value
      // }
      if (this.dict.type.sys_treatment_effect.length > 0) {
        this.treatmentItemForm.treatmentEffect = this.dict.type.sys_treatment_effect[0].value
      }
      // this.treatmentItemForm.treatmentDoctor = this.$store.state.user.nickName

    },
    /** 修改按钮操作 */
    handleUpdate() {
      this.submitStatus = false
      this.activeName = '1'
      this.recordResetQuery()
      const id = this.ids;
      this.getTreatmentDoctorUsersList()
      getTreatmentDetail(id).then(
        (response) => {
          if (response.code == 200) {
            console.log('getTreatmentDetail------', response)
            this.recordVisible = true
            this.recordTitle = '修改治疗'
            this.recordQueryParams.visitNum = response.data.visitNum
            this.btnIndex = 0
            // this.treatmentParametersList = []
            this.recordHandleQuery()
            this.treatmentItemForm = response.data
            console.log('this.treatmentItemForm++++++', this.treatmentItemForm)
            if (this.treatmentItemForm.treatmentInstrument != null && this.treatmentItemForm.treatmentInstrument != '') {
              this.treatmentItemForm.treatmentInstrument = this.treatmentItemForm.treatmentInstrument.split(',').map(Number)
            } else {
              this.treatmentItemForm.treatmentInstrument = []
            }
            if (this.treatmentItemForm.treatmentReaction != null && this.treatmentItemForm.treatmentReaction != '') {
              if (this.treatmentItemForm.treatmentReaction.includes(',')) {
                this.treatmentItemForm.treatmentReaction = this.treatmentItemForm.treatmentReaction.split(',')
                console.log(this.treatmentItemForm.treatmentReaction)
              } else {
                this.treatmentItemForm.treatmentReaction = [this.treatmentItemForm.treatmentReaction]
              }
            } else {
              this.treatmentItemForm.treatmentReaction = []
            }
            this.treatmentItemForm.treatmentPlace = this.treatmentItemForm.treatmentPlace.split(',')
            let treatmentParametersListContainer = [{ packageContent: '', num: '', spareNum: '' }]
            treatmentParametersListContainer[0].packageContent = this.treatmentItemForm.packageContent
            treatmentParametersListContainer[0].num = this.treatmentItemForm.num
            treatmentParametersListContainer[0].spareNum = this.treatmentItemForm.spareNum
            this.treatmentParametersList = treatmentParametersListContainer

            // console.log('this.treatmentParametersList',this.treatmentParametersList)
            this.uploadPackageContent = this.treatmentItemForm.packageContent

            if (this.treatmentItemForm.oldparameters) {
              this.parametersList = JSON.parse(this.treatmentItemForm.oldparameters)
            } else {
              this.parametersList = []
            }
            // console.log('this.parametersList---',this.parametersList)

          } else {
            this.$modal.msgError(response.msg);
          }
        }
      )

    },
    handleDelete() {
      const patientNames = this.patientNames;
      const id = this.ids;

      this.$confirm(` 是否确认删除顾客姓名为 <strong>(${patientNames})</strong>) 的治疗记录?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        dangerouslyUseHTMLString: true,
      })
        .then((content) => {
          deleteTreatment(id).then(
            (response) => {
              if (response.code == 200) {
                // console.log('deleteTreatment',response)
                this.getTreatmentList()
              } else {
                this.$modal.msgError(response.msg);
              }

            }
          )
          // console.log('content', content)
        })
        .catch((error) => {
          // console.log('error', error)
        })


    },
    /** 新增顾客信息----- */
    closeRecord() {
      this.recordVisible = false
      this.recordResetQuery()
      this.recordQueryParams = {
        pageNum: 1,
        pageSize: 5,
        visitNum: '',
        patientName: '',
        patientPhone: '',
        idNum: '',
      }
      this.treatmentRecordDataList = []
      this.getTreatmentList()
      this.confirmKnowNum = 0
      this.confirmPayNum = 0
      this.positionSchemeNum = 0
      this.uploadPhotosNum = 0
      this.warmReminderRecordParamsTotal = 0
      this.activeName = ''


    },
    /** 搜索按钮操作 */
    recordHandleQuery() {
      this.recordQueryParams.pageNum = 1;
      if (this.recordQueryParams.visitNum || this.recordQueryParams.patientName || this.recordQueryParams.patientPhone || this.recordQueryParams.idNum) {
        this.getRecordPatientList();
      }
    },
    /** 重置按钮操作 */
    recordResetQuery() {
      this.resetForm("recordQueryForm");
      this.resetForm("patientItemForm");
      this.resetForm("treatmentItemForm");
      this.recordQueryParams = {
        pageNum: 1,
        pageSize: 5,
        visitNum: undefined,
        patientName: undefined,
        patientPhone: undefined,
        idNum: undefined,
      }
      this.treatmentParametersList = []
      this.uploadPatientId = ''
      this.patientItem = {}
      this.doctorListCopy = []


      this.treatmentItemForm = {
        doctorDiagnosis: "",     //医生诊断
        doctorPlanId: "",        //医生方案类
        paymenVoucher: "",       //缴费凭证上传地址
        remark: "",              //备注
        treatmentAge: "",        //治疗年龄
        treatmentDoctor: "",     //治疗医生
        treatmentEffect: "",     //治疗效果
        treatmentInstrument: "", //治疗仪器
        treatmentParameter: "",  //治疗参数
        treatmentPlace: [],      //治疗部位
        treatmentPrice: null,    //治疗价格
        treatmentReaction: [],   //治疗反应
        treatmentTime: "",       //治疗时间
        visitNum: "",          //顾客编号
        pointsNum: '',            //点位数
      }
    },
    // 真实序号计算（计算分页影响）
    getRecordIndex(index) {
      return (this.recordQueryParams.pageNum - 1) * this.recordQueryParams.pageSize + index + 1;
    },
    // 查询顾客列表(治疗中或治疗结束)
    getRecordPatientList() {
      if (this.submitStatus) {
        getListForTreatment(this.recordQueryParams).then(
          (response) => {
            if (response.rows.length > 0) {
              if (response.rows.length == 1) {
                this.patientItem = response.rows[0];
                this.patientItem.birthDate = parseInt((new Date() - new Date(this.parseTime(this.patientItem.birthDate))) / (1000 * 60 * 60 * 24 * 365))
                this.uploadPatientId = response.rows[0].patientId
                if (this.submitStatus) {
                  this.getSysVisitPlans(response.rows[0].visitNum)
                }
                //获取确认缴费知情同意书角标
                this.getConsentNum(this.patientItem.visitNum, '0')
                this.getConsentNum(this.patientItem.visitNum, '1')
                this.getConsentNum(this.patientItem.visitNum, '2')
                this.getConsentNum(this.patientItem.visitNum, '3')
                this.getWarmReminderRecordcount()
                this.getTreatmentDoctorUsersListCopy()
                this.activeName = '1'
              } else {
                this.loading = true

                this.patientVisible = true
                this.recordPatientList = response.rows;

                this.recordPatientList.forEach(item => {
                  if (item.consultationDiagnosis.includes(';')) {
                    let Mobject = ''
                    item.consultationDiagnosis.split(';').forEach(it => {
                      Mobject += it + '<br>'
                    })
                    item.consultationDiagnosisValue = Mobject
                  } else {
                    item.consultationDiagnosisValue = item.consultationDiagnosis
                  }
                  if (item.doctorDiagnosis.includes(';')) {
                    let MobjectDoctor = ''
                    item.doctorDiagnosis.split(';').forEach(it => {
                      MobjectDoctor += it + '<br>'
                    })
                    item.doctorDiagnosisValue = MobjectDoctor
                  } else {
                    item.doctorDiagnosisValue = item.doctorDiagnosis
                  }
                });

                this.searchTotal = response.total;
                this.loading = false;
              }
              this.getPartTreatmentList(this.uploadPatientId)

            } else {
              // this.$modal.msgWarning("没找到对应的顾客！");
              this.$confirm('该顾客无治疗中的项目!', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              })
                .then((content) => {
                  this.recordResetQuery()
                })
                .catch((error) => {
                  this.recordResetQuery()
                })

            }


          }
        )
      } else {
        getTreatmentBy(this.recordQueryParams.visitNum).then(
          (response) => {
            if (response.code == 200) {
              this.patientItem = response.data;
              this.patientItem.birthDate = parseInt((new Date() - new Date(this.parseTime(this.patientItem.birthDate))) / (1000 * 60 * 60 * 24 * 365))
              // console.log('this.patientItem++++', this.patientItem)
              this.uploadPatientId = response.data.patientId
              //获取确认缴费知情同意书角标
              this.getConsentNum(this.patientItem.visitNum, '0')
              this.getConsentNum(this.patientItem.visitNum, '1')
              this.getConsentNum(this.patientItem.visitNum, '2')
              this.getConsentNum(this.patientItem.visitNum, '3')
              this.getWarmReminderRecordcount()
              this.getPartTreatmentList(this.uploadPatientId)
            } else {
              this.$modal.alertError(response.msg);

            }


          }
        )
      }

    },
    confirmPatient(row) {
      this.patientItem = row
      this.patientVisible = false
      this.uploadPatientId = row.patientId
      this.getSysVisitPlans(row.visitNum)
      this.getConsentNum(row.visitNum, '0')
      this.getConsentNum(row.visitNum, '1')
      this.getConsentNum(row.visitNum, '2')
      this.getConsentNum(row.visitNum, '3')
      this.getWarmReminderRecordcount()
      this.getTreatmentDoctorUsersListCopy()
      this.getPartTreatmentList(this.uploadPatientId)
      this.activeName = '1'
      // this.getConsentList(this.patientItem.visitNum, '1')
    },
    //查询该就诊编号下医生方案中治疗类的方案信息(治疗中)
    getSysVisitPlans(visitNum) {
      findSysVisitPlans(visitNum).then(
        (response) => {
          if (response.code == 200) {
            this.treatmentParametersList = response.data
            console.log('--findSysVisitPlans---', this.treatmentParametersList)
            if (this.patientItem.partArr) {
              let partArr = []
              let partArrCopy = []
              let partArrCopySet = []

              partArr = this.patientItem.partArr.split(";").map(item => {
                return JSON.parse(item)
              })
              partArr.forEach(item => {
                item.forEach(it => {
                  partArrCopy.push(it.label)
                })
              })
              partArrCopySet = [...new Set(partArrCopy)]
              this.treatmentItemForm.treatmentPlace = partArrCopySet
              // console.log('partArr----',partArr)
              // console.log('partArrCopy---',partArrCopy)
              // console.log('partArrCopy---',partArrCopySet)
            }
            this.getTreatmentParametersItem(response.data[this.btnIndex], this.btnIndex)
          } else {
            this.$modal.msgError(response.msg);
          }
        }
      )
    },

    getTreatmentParametersItem(item, index) {
      this.btnIndex = index
      this.treatmentParametersItem = item
      this.treatmentItemForm.pointsNum = this.treatmentParametersItem.pointsNum

      if (this.treatmentParametersItem.instrumentsIds != null && this.treatmentParametersItem.instrumentsIds != '') {
        this.treatmentItemForm.treatmentInstrument = this.treatmentParametersItem.instrumentsIds.split(",").map(Number)
        // console.log('this.treatmentItemForm.treatmentInstrument---', this.treatmentItemForm.treatmentInstrument)
      } else {
        this.treatmentItemForm.treatmentInstrument = []
      }
      if (this.treatmentParametersItem.parameters != null && this.treatmentParametersItem.parameters != '' && this.treatmentParametersItem.parameters != undefined) {
        this.parametersList = JSON.parse(this.treatmentParametersItem.oldparameters)
        // console.log('this.parametersList--', this.parametersList)
        // console.log('this.parametersList-111111111111111111-', this.treatmentParametersItem)
        this.treatmentItemForm.treatmentParameter = ''
        this.treatmentItemForm.remark = ''

        JSON.parse(this.treatmentParametersItem.parameters).forEach((item, index) => {
          this.treatmentItemForm.treatmentParameter += item.label + '(' + item.value + ');'
        })
        JSON.parse(this.treatmentParametersItem.remark).forEach((item, index) => {
          this.treatmentItemForm.remark += item.label + '(' + item.value + ');'
        })
      } else {
        this.treatmentItemForm.treatmentParameter = ''
        this.treatmentItemForm.remark = ''
        this.parametersList = []
      }

      // this.treatmentItemForm.treatmentParameter = this.treatmentParametersItem.parameters
      // this.treatmentItemForm.remark = this.treatmentParametersItem.parameters
      //
      // if (this.treatmentItemForm.remark != null && this.treatmentItemForm.remark != '' &&this.treatmentItemForm.remark != undefined) {
      //   this.parametersList = JSON.parse(this.treatmentParametersItem.oldparameters)
      //   // console.log('this.parametersList--', this.parametersList)
      //   // this.treatmentItemForm.treatmentParameter = ''
      //   // this.treatmentItemForm.remark = ''
      //   console.log('this.treatmentItemForm.remark --',this.treatmentItemForm.remark )
      //
      //   JSON.parse(this.treatmentItemForm.remark).forEach((item, index) => {
      //     this.treatmentItemForm.remark += item.label + '(' + item.value + ');'
      //   })
      // } else {
      //   this.parametersList = []
      // }

      this.treatmentItemForm.treatmentPrice = (this.treatmentParametersItem.discountPrice / this.treatmentParametersItem.num).toFixed(2)
      // this.treatmentItemForm.treatmentPrice = this.treatmentParametersItem.price * this.treatmentParametersItem.discount
      this.treatmentItemForm.visitNum = this.patientItem.visitNum
      this.treatmentItemForm.doctorPlanId = this.treatmentParametersItem.id
      this.treatmentItemForm.treatmentAge = this.patientItem.age
      this.treatmentItemForm.patientId = this.patientItem.patientId
      this.uploadPackageContent = this.treatmentParametersItem.packageContent

    },
    //查询设备列表 (治疗仪器列表)
    getInstrumentsList() {
      listDevice({
        pageNum: 1,
        pageSize: 9999,
        deviceName: undefined,
        status: '0',
        deviceType: '0',
        hospitalId: this.queryParams.hospitalId,
      }).then((response) => {
        this.instrumentsList = response.rows;
      });
    },
    /** 查询方案单项列表 */
    getSinglePlanList() {
      listPlan({
        pageNum: 1,
        pageSize: 9999,
        hospitalId: this.queryParams.hospitalId,


      }).then(
        (response) => {
          this.singlePlanList = response.rows;
        }
      );
    },
    getSplit(str) {
      return str.split(',')
    },
    //查询治疗医生列表
    getTreatmentDoctorUsersList() {
      getListUser({ funcRole: '3', hospitalId: this.queryParams.hospitalId, deptId: this.queryParams.deptId }).then((response) => {
        if (response.code == 200) {
          this.doctorList = response.data
          // if (this.doctorList.length > 0) {
          //   let a = this.doctorList.some(item => {
          //     return item.userName == this.userName
          //   })
          //   if (a) {
          //     this.treatmentItemForm.treatmentDoctor = this.userName
          //   }
          // }
        }
      });

    },
    //查询治疗医生列表
    getTreatmentDoctorUsersListCopy() {
      getListUser({ funcRole: '3', hospitalId: this.patientItem.hospitalId, deptId: this.patientItem.deptId }).then((response) => {
        if (response.code == 200) {
          this.doctorListCopy = response.data
          if (this.doctorList.length > 0) {
            let a = this.doctorListCopy.some(item => {
              return item.userName == this.userName
            })
            if (a) {
              this.treatmentItemForm.treatmentDoctor = this.userName
            }
          }
        }
      });

    },
    //签到
    attendItem() {//签到
      let that = this
      if (!this.patientItem.visitNum) {
        this.$modal.msgError('请选择顾客以及填写选择治疗内容!');
        return
      }
      console.log(that.treatmentParametersItem.spareNum)
      if (that.treatmentParametersItem == null || that.treatmentParametersItem == undefined || that.treatmentParametersItem.id == null || that.treatmentParametersItem.id == undefined) {
        this.$modal.msgError('请选择填写选择治疗内容!');
        return
      }
      if (that.treatmentParametersItem.spareNum <= 0) {
        this.$modal.msgError('当前选择的治疗内容余次为0，请重新选择!');
        return
      }
      let treatmentParametersItemparams = []
      let item = that.treatmentParametersItem
      let paramspatient = {
        diagnosis: that.patientItem.doctorDiagnosis,
        diagnosisPlan: that.patientItem.doctorPlan,
        diseaseId: '',
        doctorId: that.patientItem.doctorId,
        patientAge: that.patientItem.age,
        patientId: that.patientItem.patientId,
        patientName: that.patientItem.patientName,
        patientSex: that.patientItem.sex,
        signId: '',
        visitNum: that.patientItem.visitNum,
      }
      paramspatient.spareNum = item.spareNum
      paramspatient.treatmentName = item.packageContent
      paramspatient.status = item.status
      paramspatient.visitPlanId = item.id
      treatmentParametersItemparams.push(paramspatient)
      let data = treatmentParametersItemparams
      let params = []
      data.forEach(function (item, index) {
        item.type = 1

        params.push(item)
      });
      params = data
      addsign(params, 1).then((response) => {
        that.submitTreatmentItem()
      })

    },
    submitTreatmentItem() {
      if (!this.patientItem.visitNum) {
        this.$modal.msgError('请选择顾客以及填写选择治疗内容!');
        return
      }
      this.$refs["treatmentItemForm"].validate((valid) => {
        if (valid) {
          this.$confirm(`确认<strong>(${this.patientItem.patientName})</strong>的<strong>(${this.uploadPackageContent})</strong>已经治疗完成1次！`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            dangerouslyUseHTMLString: true,
          })
            .then((content) => {
              if (Array.isArray(this.treatmentItemForm.treatmentInstrument)) {
                this.treatmentItemForm.treatmentInstrument = this.treatmentItemForm.treatmentInstrument.join(",")

              }
              if (Array.isArray(this.treatmentItemForm.treatmentPlace)) {
                this.treatmentItemForm.treatmentPlace = this.treatmentItemForm.treatmentPlace.join(",")
              }
              if (Array.isArray(this.treatmentItemForm.treatmentReaction)) {
                this.treatmentItemForm.treatmentReaction = this.treatmentItemForm.treatmentReaction.join(",")
              }
              this.treatmentItemForm.treatmentTime = this.parseTime(this.treatmentItemForm.treatmentTime)
              if (this.treatmentParametersItem.oldparameters) {
                this.treatmentItemForm.oldparameters = this.treatmentParametersItem.oldparameters
              }
              let a = this.doctorList.find(item => {
                return item.userName == this.treatmentItemForm.treatmentDoctor
              })
              if (a) {
                this.treatmentItemForm.treatmentDoctorName = a.nickName
              }

              addTreatment(this.treatmentItemForm).then(
                (response) => {
                  if (response.code == 200) {
                    this.$modal.msgSuccess(response.msg);
                    this.treatmentItemForm.treatmentInstrument = this.treatmentItemForm.treatmentInstrument.split(",")
                    this.treatmentItemForm.treatmentPlace = this.treatmentItemForm.treatmentPlace.split(',')
                    this.treatmentItemForm.treatmentReaction = this.treatmentItemForm.treatmentReaction.split(',')
                    this.getSysVisitPlans(this.patientItem.visitNum)
                    this.recordVisible = false
                    this.handleQuery()

                  } else {
                    // this.$modal.msgError(response.msg);
                    this.treatmentItemForm.treatmentInstrument = this.treatmentItemForm.treatmentInstrument.split(",")
                    this.treatmentItemForm.treatmentPlace = this.treatmentItemForm.treatmentPlace.split(',')
                    this.treatmentItemForm.treatmentReaction = this.treatmentItemForm.treatmentReaction.split(',')
                    this.getSysVisitPlans(this.patientItem.visitNum)
                  }
                }
              )

            })
            .catch((error) => {
              // console.log(error)
            })
        }
      });

    },
    updateTreatmentItem() {
      if (!this.patientItem.visitNum) {
        this.$modal.msgError('请选择顾客以及填写选择治疗内容!');
        return
      }
      this.$refs["treatmentItemForm"].validate((valid) => {
        if (valid) {
          this.$confirm(`确认<strong>(${this.patientItem.patientName})</strong>的<strong>(${this.uploadPackageContent})</strong>修改记录！`, '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
            dangerouslyUseHTMLString: true,
          })
            .then((content) => {
              if (Array.isArray(this.treatmentItemForm.treatmentInstrument)) {
                this.treatmentItemForm.treatmentInstrument = this.treatmentItemForm.treatmentInstrument.join(",")
              }
              if (Array.isArray(this.treatmentItemForm.treatmentPlace)) {
                this.treatmentItemForm.treatmentPlace = this.treatmentItemForm.treatmentPlace.join(",")
              }
              if (Array.isArray(this.treatmentItemForm.treatmentReaction)) {
                this.treatmentItemForm.treatmentReaction = this.treatmentItemForm.treatmentReaction.join(",")
              }
              this.treatmentItemForm.treatmentTime = this.parseTime(this.treatmentItemForm.treatmentTime)
              let a = this.doctorList.find(item => {
                return item.userName == this.treatmentItemForm.treatmentDoctor
              })
              if (a) {
                this.treatmentItemForm.treatmentDoctorName = a.nickName
              }

              delete this.treatmentItemForm.packageContent
              delete this.treatmentItemForm.num
              delete this.treatmentItemForm.spareNum
              delete this.treatmentItemForm.createTime
              updateTreatment(this.treatmentItemForm).then(
                (response) => {
                  if (response.code == 200) {
                    this.$modal.msgSuccess(response.msg);
                    this.treatmentItemForm.treatmentInstrument = this.treatmentItemForm.treatmentInstrument.split(",")
                    this.treatmentItemForm.treatmentPlace = this.treatmentItemForm.treatmentPlace.split(',')
                    this.treatmentItemForm.treatmentReaction = this.treatmentItemForm.treatmentReaction.split(',')
                    this.recordVisible = false
                    this.handleQuery()

                  } else {
                    this.$modal.msgError(response.msg);
                    this.treatmentItemForm.treatmentInstrument = this.treatmentItemForm.treatmentInstrument.split(",")
                    this.treatmentItemForm.treatmentPlace = this.treatmentItemForm.treatmentPlace.split(',')
                    this.treatmentItemForm.treatmentReaction = this.treatmentItemForm.treatmentReaction.split(',')
                  }
                }
              )

            })
            .catch((error) => {
              // console.log(error)
            })
        }
      });
    },

    //确认上传照片图片
    handleCloseUploadPhotos(type) {
      if (this.uploadPhotosBlobs.length == 0) {
        this.$modal.msgWarning("请上传图片");
        return
      }
      this.loading = true

      // 创建FormData对象，通过该对象实现批量文件上传
      let fd = new FormData()
      // 因为要上传多个文件，所以需要遍历一下才行,不要直接使用我们的文件数组进行上传，你会发现传给后台的是两个Object
      this.uploadPhotosBlobs.forEach(function (file) {
        // 遍历files数组，将file添加到FormData对象中
        fd.append("files", file, file.name)
        // console.log('fd.append',file,fd.getAll('files'))
      })
      let Mdata = {
        type: type,
        visitNum: this.patientItem.visitNum,
        data: fd,
      }
      consentUploads(Mdata).then(
        (response) => {
          if (response.code == 200) {
            this.loading = false
            this.getConsentNum(this.patientItem.visitNum, '3')
            this.$modal.msgSuccess(response.msg);
            this.uploadPhotosVisible = false
            this.uploadPhotosBlobs = [] //获取的本地上传照片信息
            this.uploadPhotosImageInfo = [] //上传的上传照片信息

          } else {
            this.loading = false
            this.$modal.msgError(response.msg);

          }
        }
      )
    },
    //删除上传照片图片
    removeImgUploadPhotos(img, index) {
      this.$confirm('此操作将删除该照片, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.uploadPhotosImageInfo = this.uploadPhotosImageInfo.filter(item => {
            return item.url != img.url
          })
          this.uploadPhotosBlobs.splice(index, 1)

        })
        .then(() => {
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    //获取上传照片图片
    async uploadImageUploadPhotos() {
      const uploadPhotosBlobs = await fileOpen({
        mimeTypes: ['image/*'],
        multiple: true,
      });
      this.uploadPhotosBlobs.push(...uploadPhotosBlobs)
      this.uploadPhotosImageInfo = []
      this.uploadPhotosBlobs.forEach((item, index) => {
        const reader = new FileReader();
        reader.readAsDataURL(item)
        reader.onload = () => {
          this.uploadPhotosImageInfo.push({ url: reader.result })
        };
      })
    },
    //关闭上传治疗照片
    closeUploadPhotos() {
      this.uploadPhotosVisible = false
      this.uploadPhotosBlobs = [] //获取的本地上传照片信息
      this.uploadPhotosImageInfo = [] //上传的上传照片信息
    },
    //打开上传治疗照片
    uploadPhotos() {
      this.uploadPhotosVisible = true
      this.getConsentList(this.patientItem.visitNum, '3')
    },
    //确认部位示意
    handleClosePositionScheme(type) {
      if (this.positionSchemeBlobs.length == 0) {
        this.$modal.msgWarning("请上传图片");
        return
      }
      this.loading = true

      // 创建FormData对象，通过该对象实现批量文件上传
      let fd = new FormData()
      // 因为要上传多个文件，所以需要遍历一下才行,不要直接使用我们的文件数组进行上传，你会发现传给后台的是两个Object
      this.positionSchemeBlobs.forEach(function (file) {
        // 遍历files数组，将file添加到FormData对象中
        fd.append("files", file, file.name)
        // console.log('fd.append',file,fd.getAll('files'))
      })
      let Mdata = {
        type: type,
        visitNum: this.patientItem.visitNum,
        data: fd,
      }
      consentUploads(Mdata).then(
        (response) => {
          if (response.code == 200) {
            this.loading = false
            this.getConsentNum(this.patientItem.visitNum, '2')
            this.$modal.msgSuccess(response.msg);
            this.positionSchemeVisible = false
            this.positionSchemeBlobs = [] //获取的本地部位示意照片信息
            this.positionSchemeImageInfo = [] //上传的部位示意照片信息

          } else {
            this.loading = false
            this.$modal.msgError(response.msg);

          }
        }
      )
    },
    //删除部位示意图片
    removeImgPositionScheme(img, index) {
      this.$confirm('此操作将删除该照片, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.positionSchemeImageInfo = this.positionSchemeImageInfo.filter(item => {
            return item.url != img.url
          })
          this.positionSchemeBlobs.splice(index, 1)

        })
        .then(() => {
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    //获取部位示意图片
    async uploadImagePositionScheme() {
      const positionSchemeBlobs = await fileOpen({
        mimeTypes: ['image/*'],
        multiple: true,
      });
      this.positionSchemeBlobs.push(...positionSchemeBlobs)
      this.positionSchemeImageInfo = []
      this.positionSchemeBlobs.forEach((item, index) => {
        const reader = new FileReader();
        reader.readAsDataURL(item)
        reader.onload = () => {
          this.positionSchemeImageInfo.push({ url: reader.result })
        };
      })
    },
    //关闭部位示意图
    closePositionScheme() {
      this.positionSchemeVisible = false
      this.positionSchemeBlobs = [] //获取的本地部位示意照片信息
      this.positionSchemeImageInfo = [] //上传的部位示意照片信息
    },
    //打开部位示意图
    positionScheme() {
      this.positionSchemeVisible = true
      this.getConsentList(this.patientItem.visitNum, '2')

    },

    //确认缴费
    handleCloseConfirmPay(type) {
      this.loading = true
      if (this.confirmPayBlobs.length > 0) {
        // 创建FormData对象，通过该对象实现批量文件上传
        let fd = new FormData()
        // 因为要上传多个文件，所以需要遍历一下才行,不要直接使用我们的文件数组进行上传，你会发现传给后台的是两个Object
        this.confirmPayBlobs.forEach(function (file) {
          // 遍历files数组，将file添加到FormData对象中
          fd.append("files", file, file.name)
          // console.log('fd.append',file,fd.getAll('files'))
        })
        let Mdata = {
          type: type,
          visitNum: this.patientItem.visitNum,
          data: fd,
        }
        consentUploads(Mdata).then(
          (response) => {
            if (response.code == 200) {
              this.loading = false
              this.$modal.msgSuccess(response.msg);
              this.confirmPayVisible = false
              this.confirmPayBlobs = []//获取的本地缴费确认照片信息
              this.confirmPayImageInfo = []//上传的缴费确认照片信息
              this.patientItem.confirmExpense = '1'
              this.getConsentNum(this.patientItem.visitNum, '0')

            } else {
              this.loading = false
              this.$modal.msgError(response.msg);
            }
          }
        )
      } else {
        let Mdata1 = {
          type: type,
          visitNum: this.patientItem.visitNum,
          data: '',
        }
        consentUploads(Mdata1).then(
          (response) => {
            if (response.code == 200) {
              this.$modal.msgSuccess(response.msg);
              this.loading = false
              this.confirmPayVisible = false
              this.patientItem.confirmExpense = '1'

            } else {
              this.$modal.msgError(response.msg);
              this.loading = false
            }
          }
        )
      }

    },
    //删除图片
    removeImgConfirmPay(img, index) {
      this.$confirm('此操作将删除该照片, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.confirmPayImageInfo = this.confirmPayImageInfo.filter(item => {
            return item.url != img.url
          })
          this.confirmPayBlobs.splice(index, 1)
          console.log('this.confirmPayBlobs', this.confirmPayBlobs)

        })
        .then(() => {
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    },
    //获取图片
    async uploadImageConfirmPay() {
      const confirmPayBlobs = await fileOpen({
        mimeTypes: ['image/*'],
        multiple: true,
      });
      this.confirmPayBlobs.push(...confirmPayBlobs)
      this.confirmPayImageInfo = []
      this.confirmPayBlobs.forEach((item, index) => {
        const reader = new FileReader();
        reader.readAsDataURL(item)
        reader.onload = () => {
          this.confirmPayImageInfo.push({ url: reader.result })
        };
      })
      console.log('this.confirmPayImageInfo', this.confirmPayImageInfo)
    },
    //关闭缴费确认
    closeConfirmPay() {
      this.confirmPayVisible = false
      this.confirmPayBlobs = []//获取的本地缴费确认照片信息
      this.confirmPayImageInfo = []//上传的缴费确认照片信息
    },
    //打开缴费确认
    confirmPay() {
      this.confirmPayVisible = true
      this.getConsentList(this.patientItem.visitNum, '0')
    },
    //确认已签署
    handleCloseConfirmKnow(type) {
      if (this.blobs.length == 0) {
        this.$modal.msgWarning("请上传图片");
        return
      }
      this.loading = true

      // 创建FormData对象，通过该对象实现批量文件上传
      let fd = new FormData()
      // 因为要上传多个文件，所以需要遍历一下才行,不要直接使用我们的文件数组进行上传，你会发现传给后台的是两个Object
      this.blobs.forEach(function (file) {
        // 遍历files数组，将file添加到FormData对象中
        fd.append("files", file, file.name)
        // console.log('fd.append',file,fd.getAll('files'))
      })
      let Mdata = {
        type: type,
        visitNum: this.patientItem.visitNum,
        data: fd,
      }
      consentUploads(Mdata).then(
        (response) => {
          if (response.code == 200) {
            this.loading = false
            this.getConsentNum(this.patientItem.visitNum, '1')
            this.$modal.msgSuccess(response.msg);
            this.confirmKnowVisible = false
            this.blobs = []//获取的知情同意书照片信息
            this.imageInfo = []//上传的本地知情同意书照片信息

          } else {
            this.loading = false
            this.$modal.msgError(response.msg);

          }
        }
      )
    },
    //删除图片
    removeImg(img, idx) {
      this.$confirm('此操作将删除该照片, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.imageInfo = this.imageInfo.filter(item => {
            return item.url != img.url
          })
          this.blobs.splice(idx, 1)

        })
        .then(() => {
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })

    },
    //获取图片
    async uploadImage() {
      const blobs = await fileOpen({
        mimeTypes: ['image/*'],
        multiple: true,
      });

      this.blobs.push(...blobs)
      // console.log('uploadImage-blobs-',this.blobs )
      this.imageInfo = []
      this.blobs.forEach((item, index) => {
        const reader = new FileReader();
        reader.readAsDataURL(item)
        reader.onload = () => {
          this.imageInfo.push({ url: reader.result })
        };
      })
      console.log('imageInfo--', this.imageInfo)
    },
    //关闭知情同意书
    closeConfirmKnow() {
      this.confirmKnowVisible = false
      this.blobs = []//获取的知情同意书照片信息
      this.imageInfo = []//上传的本地知情同意书照片信息
    },
    //打开知情同意书
    confirmKnow() {
      this.confirmKnowVisible = true
      this.getConsentList(this.patientItem.visitNum, '1')
    },
    //获取知情同意书角标
    getConsentNum(visitNum, type) {
      consentNum(visitNum, type).then(
        (response) => {
          if (response.code == 200) {
            if (type == '0') {
              this.confirmPayNum = response.data
            } else if (type == '1') {
              this.confirmKnowNum = response.data
            } else if (type == '2') {
              this.positionSchemeNum = response.data
            } else {
              this.uploadPhotosNum = response.data
            }
          } else {
            this.$modal.msgError(response.msg);

          }
        }
      )
    },
    //获取已上传的缴费凭证或知情同意书
    getConsentList(visitNum, type) {
      consentList(visitNum, type).then(
        (response) => {
          if (response.code == 200) {
            if (type == '0') {
              this.confirmPayImageInfo = response.data
              this.confirmPayImageInfo.forEach((item) => {
                item.url = this.baseUrl + item.url
              })

            } else if (type == '1') {
              this.imageInfo = response.data
              this.imageInfo.forEach((item) => {
                item.url = this.baseUrl + item.url
              })
            } else if (type == '2') {
              this.positionSchemeImageInfo = response.data
              this.positionSchemeImageInfo.forEach((item) => {
                item.url = this.baseUrl + item.url
              })
            } else {
              this.uploadPhotosImageInfo = response.data
              this.uploadPhotosImageInfo.forEach((item) => {
                item.url = this.baseUrl + item.url
              })
            }
          } else {
            this.$modal.msgError(response.msg);

          }
        }
      )
    },
    //温馨提示
    warmReminder() {
      this.warmReminderVisible = true
    },
    closeWarmReminderVisible() {
      this.warmReminderVisible = false
      this.getWarmReminderRecordcount()
    },
    //获取温馨提示角标
    getWarmReminderRecordcount() {
      let warmReminderRecordParams = {
        pageNum: 1,
        pageSize: 10,
        visitNum: '',
      }
      warmReminderRecordParams.visitNum = this.patientItem.visitNum
      getTipsList(warmReminderRecordParams).then(response => {
        if (response.code == 200) {
          this.warmReminderRecordParamsTotal = response.total
          console.log('this.warmReminderRecordParamsTotal---', this.warmReminderRecordParamsTotal)
        } else {

        }
      })
    },
    //调取摄像头拍摄
    openShooting(type) {
      this.cameraShootingVisible = true
      this.cameraShootingType = type

    },
    //关闭摄像头拍摄
    closeShooting(imgSrc, imgFile) {
      this.cameraShootingVisible = false
      console.log('closeShooting', imgSrc, imgFile)
      if (this.cameraShootingType == '0') {
        this.confirmPayBlobs = []
        this.confirmPayImageInfo = []
        this.confirmPayBlobs.push(imgFile)
        this.confirmPayImageInfo.push({ url: imgSrc })
      } else if (this.cameraShootingType == '1') {
        this.blobs = []
        this.imageInfo = []
        this.blobs.push(imgFile)
        this.imageInfo.push({ url: imgSrc })
      } else if (this.cameraShootingType == '3') {
        this.uploadPhotosBlobs = []
        this.uploadPhotosImageInfo = []
        this.uploadPhotosBlobs.push(imgFile)
        this.uploadPhotosImageInfo.push({ url: imgSrc })
      }
    },
    handleChange(val) {
      // console.log('handleChange',val);
    },
    openCollapse() {
      this.activeName1 = '1'
    },


  },
};
</script>
<style scoped rel="stylesheet/scss"  lang="scss">
::v-deep .el-form-item.is-required:not(.is-no-asterisk)>.el-form-item__label:before,
.el-form-item.is-required:not(.is-no-asterisk) .el-form-item__label-wrap>.el-form-item__label:before {
  display: inline-block;
  content: '*';
  color: red;
  margin-left: 4px;
}

::v-deep .el-form-item.is-required:not(.is-no-asterisk)>.el-form-item__label::after,
.el-form-item.is-required:not(.is-no-asterisk) .el-form-item__label-wrap>.el-form-item__label::after {
  display: none;
}

::v-deep .el-input.is-disabled .el-input__inner {
  color: #606266;
}

.uploadBtnBox {
  display: flex;

  .btn {
    margin-left: 10px;
  }
}

.positionSchemeBox {
  display: flex;
  justify-content: space-between;
}

.uploadImageBox {
  //width: 500px;
  min-height: 500px;
  border: 1px solid #f3a4a1;
  margin: 10px auto;
}

.formBtn {
  margin: 0 auto;
  display: block;
}

.img-style {
  width: 500px;
  height: 500px;

  ::v-deep .el-image__error {
    opacity: 0;
  }
}

::v-deep .el-textarea__inner {
  font-size: 14px;
  font-weight: bold;
  color: blue;
}

::v-deep .el-input.is-disabled .el-input__inner {
  color: #606266;
}

::v-deep .inputRed.el-input.is-disabled .el-input__inner {
  color: red;
}

::v-deep .el-textarea.is-disabled .el-textarea__inner {
  color: #606266;
}


.treatmentParametersListBox {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;

  .smallBox {
    margin-right: 10px;
    margin-bottom: 10px;
    font-size: 18px;

    .numBox {
      font-weight: bold;
      color: red;
      font-size: 20px;
    }
  }


}

.treatmentParametersListBoxBtn {
  display: flex;
  align-items: center;

  //max-width: 990px;
  //border: 1px solid #C0C4CC;
  .el-form-item {
    margin-top: 10px;
  }

  .smallTitle {
    margin-left: 15px;
    color: red;
  }

}

::v-deep .el-dialog {
  margin-top: 0 !important;
}

.draggable-item {
  display: inline-block;
  margin: 0 8px 8px 0;
  font-size: 0;
  line-height: 0;
  vertical-align: middle;
  position: relative;
}

.upload-img {
  display: inline-block;
  margin: 0 8px 8px 0;
  font-size: 0;
  line-height: 0;
  overflow: hidden;
  vertical-align: middle;
}

.icon-close {
  position: absolute;
  right: 0;
  top: 0;
  font-size: 18px;
  color: #00be8b;
  z-index: 1;
}

.mt15 {
  ::v-deep .el-collapse-item__header {
    border: none;
  }

  .mt10 {
    margin-top: 10px;
  }
}

.treatmentInlineBox {
  display: flex;
  flex-wrap: wrap;
}

.totalItem {
  margin: 0 15px;
}
</style>
